//
//  APNsWebService.m
//  YYZB
//
//  Created by 顾悦 on 16/4/5.
//
//

#import "APNsWebService.h"

@implementation APNsWebService

- (void)registerUserInfoByID:(NSString *)ID
                        imie:(NSString *)imie
                  registerId:(NSString *)registerId
                   accountNo:(NSString *)accountNo
                     appType:(NSString *)appType
           completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder {
    NSString *URL = @"Push/Register";
    NSDictionary *params = @{
                             @"UserId": ID,
                             @"Imie": imie,
                             @"RegisterId": registerId,
                             @"DeviceType": @"ios",
                             @"AccountNo": accountNo,
                             @"AppType": appType
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:NO];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}

- (void)fetchUserTagByUserType:(NSString *)userType // 1 客户端 2 服务端
             completionHanlder:(void (^)(NSArray *items, NSError *error))completionHanlder  {
    NSString *URL = @"Push/GetUserLabel";
    NSDictionary *params = @{
                             @"UserType": userType,
                             };
    NSString *URLString = [self formattedURLString:params method:URL sessionNeeded:NO];
    [self sendHTTPGetRequest:URLString completionHandler:^(id result, NSError *error) {
        if (error != nil) {
            completionHanlder(nil, error);
        } else {
            NSError *err;
            NSArray *items = [self unboxedValue:result error:&err];
            completionHanlder(items, err);
        }
    }];
}

@end
